#!/bin/sh

uci -q batch <<-EOF >/dev/null
	delete ucitrack.@frpc[-1]
	add ucitrack frpc
	set ucitrack.@frpc[-1].init=frpc
	commit ucitrack
EOF

frpc=$(uci -q get frpc.@frpc[-1])

if [ -z "$frpc" ]; then
	uci -q add frpc frpc
fi

if [ "x$frpc" != "xmain" ]; then
	uci -q batch <<-EOF >/dev/null
		rename frpc.@frpc[-1]="main"
		set frpc.main.enabled="0"
		commit frpc
	EOF
fi

rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
exit 0
